#!/bin/bash

members=("node1" "node2" "node3")

for((i=0; i<${#members[@]}; i++))
do 
	cmd="systemctl stop ceph-mon@${members[$i]}"
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="systemctl stop ceph-mgr@${members[$i]}"
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="systemctl stop ceph-mds@${members[$i]}"
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="systemctl stop ceph-radosgw@rgw.${members[$i]}"
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="kill \$(ps -ef | grep -i \"ceph\" | awk '(\$1==\"ceph\") {print \$2}')"   ## kill osd daemons
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="kill \$(ps -ef | grep -i \"ceph\" | awk '(\$1==\"root\") {print \$2}')"   ## kill ceph-crash daemons
	ssh root@${members[$i]} $cmd
	#echo $cmd
	cmd="dnf remove ceph.x86_64 ceph-radosgw.x86_64 -y"  ## uninstall ceph & ceph-radosgw
	ssh root@${members[$i]} $cmd
	#cmd="rm -rf /var/lib/ceph"  ## remove all ceph data
	#ssh root@${members[$i]} $cmd
	cmd="vgremove \$(vgs | awk '(\$1!=\"VG\"&&\$1!=\"cl\"){print \$1}') -y" ## remove lvm config
	ssh root@${members[$i]} $cmd
done
